package com.testfileupload.uploadimg.design.iterator.define;

import java.util.Vector;

public class ConcreateIterator implements Iterator {
    private Vector vector = new Vector();
    //定义当前游标
    public int cursor = 0;

    public ConcreateIterator(Vector vector) {
        this.vector = vector;
    }


    @Override
    public Object next() {
        Object object = null;
        if (this.hasNext()) {
            object = this.vector.get(this.cursor++);
        } else {
            object = null;
        }
        return object;
    }

    @Override
    public boolean hasNext() {
        //判断是否到达尾部
        if (this.cursor == this.vector.size()) {
            return false;
        } else {
            return true;
        }
    }

    @Override
    public boolean remove() {
        Object remove = this.vector.remove(this.cursor);
        return true;
    }
}
